package itsm.isperp.module.service.incident;

import itsm.isperp.framework.core.context.ContextHolder;
import itsm.isperp.framework.service.BaseService;
import itsm.isperp.module.entity.incident.IcdMajorMember;
import itsm.isperp.module.repository.incident.IcdMajorMemberMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * 服务
 * 
 * @author lizx
 * @date 2016-11-28 09:29
 */
@Service
public class IcdMajorMemberService extends BaseService<IcdMajorMember> {

	@Autowired
	protected IcdMajorMemberMapper icdMajorMemberMapper;

	@Override
	public IcdMajorMemberMapper getRepository() {
		return this.icdMajorMemberMapper;
	}

	public boolean isMember(String incidentId, String username) {
		JdbcTemplate jdbcTemplate = ContextHolder.getSpringBean("jdbcTemplate");
		String sql = "SELECT count(*) FROM icd_major_member WHERE incident_id='"
				+ incidentId + "' AND username='" + username + "'";
		int c = jdbcTemplate.queryForObject(sql, Integer.class);

		return c > 0;
	}

}
